package com.kaifamiao.demo.d0903;

import java.sql.*;

public class Demo01 {

    public static void main(String[] args) {
        try {
            // 加载驱动
            Class.forName("com.mysql.cj.jdbc.Driver");
            // 连接数据库
            String url = "jdbc:mysql://localhost:3306/kfm";
            Connection connection = DriverManager.getConnection(url, "root", "");

            // Statement
            Statement statement = connection.createStatement();

            String sql = """
                      select * from users
                    """;
            ResultSet resultSet = statement.executeQuery(sql);

            while (resultSet.next()){
//                resultSet.getInt(1);
                resultSet.getInt("id");
            }


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
